package com.dayuanit.dy15.atm.controller;

import com.dayuanit.dy15.atm.dto.ResponseDTO;
import com.dayuanit.dy15.atm.entity.AtmUser;
import com.dayuanit.dy15.atm.service.AtmUserService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * (AtmUser)表控制层
 *
 * @author makejava
 * @since 2020-05-23 11:48:33
 */
@RestController
@RequestMapping("/user")
public class AtmUserController extends BaseController{
    /**
     * 服务对象
     */
    @Resource
    private AtmUserService userService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public ResponseDTO selectOne(Long id) {
        AtmUser atmUser = userService.queryById(id);
        return ResponseDTO.success().data("atmUser",atmUser);
    }

    @PostMapping("/upload")
    public ResponseDTO avatarUpload(MultipartFile multipartFile){
        String url = userService.avatarUpload(multipartFile);
        if(null != url){
            return ResponseDTO.success().data("url",url);
        }
        return ResponseDTO.error().message("头像上传失败");
    }



}
